﻿using System.Configuration;

namespace visinia.SmartEngine.Providers
{
    /// <summary>
    /// The visinia data provider structure in the web.config file
    /// </summary>
    public class DataProviderSection : ConfigurationSection
    {
        [ConfigurationProperty("providers")]
        public ProviderSettingsCollection Providers
        {
            get { return (ProviderSettingsCollection)base["providers"]; }
        }
        [StringValidator(MinLength = 1)]
        [ConfigurationProperty("defaultProvider", DefaultValue = "SqlDataProvider")]
        public string DefaultDataProvider
        {
            get { return (string)base["defaultProvider"]; }
            set { base["defaultProvider"] = value; }
        }

        [StringValidator(MinLength = 1)]
        [ConfigurationProperty("connectionString", DefaultValue = "connectionString")]
        public string DefaultDataProviderConnectionString
        {
            get
            {
                return Providers[DefaultDataProvider].Parameters["connectionString"];                
            }            
        }
    }
}
